package org.example.everyday;

import java.util.Map;

/**
 * <p>
 * Description:TODO 详细描述
 * <p>
 * Copyright: 天津联想协同科技有限公司
 * <p>
 *
 * @author anlu
 * @date 2022/4/26 11:29
 */
public class Lc883 {
    public static void main(String[] args) {
        Lc883 lc883 = new Lc883();
        int[][] grid = {{1,2},{3,4}};
        int res = lc883.projectionArea(grid);
        System.out.println(res);
    }

    public int projectionArea(int[][] grid) {
        int n = grid.length;
        int xyArea = 0, yzArea = 0,zxArea = 0;
        for(int i = 0; i < n; i++){
            int yzHeight = 0, zxHeight = 0;
            for(int j = 0; j < n; j++){
                xyArea += grid[i][j] > 0 ? 1 : 0;
                yzHeight = Math.max(yzHeight,grid[j][i]);
                zxHeight = Math.max(zxHeight,grid[i][j]);
            }
            yzArea += yzHeight;
            zxArea += zxHeight;
        }
        return xyArea + yzArea + zxArea;
    }
}
